package com.ats.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ats.service.JobRecordSerivce_xh;
import com.ats.service.TeacherService_xh;
import com.ats.serviceimpl.JobRecordSerivceImpl_xh;
import com.ats.serviceimpl.TeacherServiceImpl_xh;

/**
 * 审核作业
 * @author xh
 *
 */
public class AuditController_xh extends HttpServlet{
	JobRecordSerivce_xh jrs =new JobRecordSerivceImpl_xh();
	TeacherService_xh tes =new TeacherServiceImpl_xh();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		resp.setCharacterEncoding("utf8");
		PrintWriter  pw = resp.getWriter();
		int grade =Integer.parseInt(req.getParameter("grade"));
		int jrid =Integer.parseInt(req.getParameter("jrid"));
		int uid =Integer.parseInt(req.getParameter("uid"));
		//查询老师ID，根据用户ID
		int tid =tes.findTidByUid(uid);
		//审核作业
		boolean flag =jrs.updateJobRecordByTidAndJrid(grade, jrid, tid);
		pw.write(flag+"");
		pw.flush();
		pw.close();	
	}
}
